home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / langs / dl_exsrc.zoo / pfindfil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-03  |  738 b   |  32 lines

  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <support.h>
  4. #include "extras.h"
  5.  
  6. char *pfindfile(path, afn, ext)
  7.   const char *path, *afn, *ext;
  8. {
  9.   register char * const *ext_list;
  10.   register const char *x;
  11.   register int n_ext, i;
  12.   char *retval;
  13.  
  14.   if (!ext)
  15.     return findfile(afn, path, (char * const *)0);
  16.  
  17.   for (n_ext = 0, x = ext; *x; n_ext++, x += strlen(x) + 1)
  18.     continue;
  19.   ext_list = (char * const *)malloc((n_ext + 1) * sizeof(const char *));
  20.   for (i = 0, x = ext; i < n_ext; i++, x += strlen(x) + 1) {
  21.     if (*x =='.')
  22.       ext_list[i] = x + 1;
  23.     else
  24.       ext_list[i] = x;
  25.   }
  26.   ext_list[n_ext] = 0;
  27.  
  28.   retval = findfile(afn, path, ext_list);
  29.   free(ext_list);
  30.   return retval;
  31. }
  32.